package com.chance.cc.crawler.development.bootstrap.autohome.carSeriesPraise;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.downloader.proxy.Proxy;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

import static com.chance.cc.crawler.core.CrawlerEnum.CrawlerRequestType.*;

public class AutoHomePraiseStart {

    private static Proxy proxy = new Proxy();
    static {
        //代理配置
        //H5168QRFNIU3804D
        //5F6B3610BB719FAA
        proxy.setHost("http-dyn.abuyun.com");
        proxy.setPort(9020);
        proxy.setUsername("HL89Q19E86E2987D");
        proxy.setPassword("71F33D94CE5F7BF2");
    }


    public static void main(String[] args) {
        String domain = "autohome";
        String site = "carSeriesKouBei";
        String url = "https://car.autohome.com.cn/javascript/NewSpecCompare.js?20131010";
//        String url = "https://www.autohome.com.cn/135";

        CrawlerRequestRecord crawlerRequestRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(domain)
                .httpUrl(url)
                .recordKey(url)
                .releaseTime(System.currentTimeMillis())
                .filter(CrawlerEnum.CrawlerRecordFilter.key)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(domain))
                .proxy(proxy)
                .build();
        crawlerRequestRecord.getHttpRequest().setResponseCharset("GBK");
        crawlerRequestRecord.tagsCreator().bizTags().addDomain(domain);
        crawlerRequestRecord.tagsCreator().bizTags().addSite(site);

        CrawlerRequestRecord keywordRecord = CrawlerRequestRecord.builder()
                .startPageRequest("autohome_series_keyword",turnPageItem)
                .httpUrl("http://192.168.1.215:9599/v1/meta/autohome/keys?site=carSeriesKouBei")
                .requestLabelTag(supportSource)
                .requestLabelTag(internalDownload)
                .build();

        DevCrawlerController.builder()
                .triggerInfo(domain, domain, System.currentTimeMillis(), domain)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline("kafka")
                .fileResultPipeline("kafka","D:\\chance_log\\autoHomeApp\\carSeriesKouBeiKafka-8-3_1.log",false)
                .requestRecord(crawlerRequestRecord)
                .supportRecord(keywordRecord)//加载关键字
                .build("com.chance.cc.crawler.development.scripts.autohome")
                .start();
    }
}
